package com.candy.bank;

/**
 * @author donglin
 * @Title:
 * @类名: Client  客户
 * @date 2020/6/1
 */
public class Client extends Thread{
    //取款金额
    private int want;
    //共享资源，银行
    private Bank bank;

    public Client(String name, int want, Bank bank) {
        super(name);
        this.want = want;
        this.bank = bank;
    }

    @Override
    public void run() {
        int money=0;
        //判断，取款金额大于0时，正常进行取款操作，（若取款失败，则money值为0，取款结束）
        while ((money=this.bank.getMoney(want))>0){

        }
        System.out.println("取款结束");

    }
}
